package com.krmes.mes.ui.dialog;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager.LayoutParams;
import android.widget.TextView;

import com.krmes.mes.R;

public class ImageMenuDialog extends CommonDialog implements OnClickListener {
    private OnMenuClickListener mListener;

    public interface OnMenuClickListener {
        void onClick(TextView textView);
    }

    private ImageMenuDialog(Context context, boolean flag, OnCancelListener listener) {
        super(context, flag, listener);
    }

    @SuppressLint({"InflateParams"})
    private ImageMenuDialog(Context context, int defStyle) {
        super(context, defStyle);
        View view = getLayoutInflater().inflate(R.layout.dialog_image_menu, null);
        view.findViewById(R.id.menu1).setOnClickListener(this);
        view.findViewById(R.id.menu2).setOnClickListener(this);
        view.findViewById(R.id.menu3).setOnClickListener(this);
        setContent(view);
    }

    public ImageMenuDialog(Context context) {
        this(context, R.style.dialog_bottom);
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        getWindow().setGravity(80);
        Display d = getWindow().getWindowManager().getDefaultDisplay();
        LayoutParams p = getWindow().getAttributes();
        p.width = d.getWidth();
        getWindow().setAttributes(p);
    }

    public void setOnMenuClickListener(OnMenuClickListener lis) {
        this.mListener = lis;
    }

    public void onClick(View v) {
        if (this.mListener != null) {
            this.mListener.onClick((TextView) v);
        }
    }
}
